package com.lh.learning.mq.rabbitmq;


import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Component
@RocketMQMessageListener(topic = "topic-1", consumerGroup = "consumer-group-1")
public class RocketMqConsumer1 implements RocketMQListener<String> {

    @Override
    public void onMessage(String s) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        System.out.println("接收到消息:" + s+"->"+formatter.format(LocalDateTime.now()));
    }
}
